import request from '../../util/request.js'

const getToken = (params) => {
  
  return new Promise((resolve, reject) => { 
    if (!params.appid || !params.secret)  reject('error params') 
    request(`https://api.weixin.qq.com/sns/oauth2/access_token?appid=${params.appid}&secret=${params.secret}&code=${params.code}&grant_type=authorization_code`)
    .then((result) => {
      resolve(result)
    }).catch((err) => {
      reject(err)
    });
   })

}

export default getToken